

let sexs = document.getElementsByName("sex");
let sex = 0
let vips = document.getElementsByName("vip");
let vip = 0


document.querySelector('#btn_sub').addEventListener('click', e => {
  e.stopPropagation()
  e.preventDefault()
  if (sexs[0].checked) {
    sex = 1
  }

  if (vips[0].checked) {
    vip = 1
  }


  function fn(username) {
    return document.querySelector(username).value
  }
  let data = {
    username: fn("#username"),
    password: fn("#password"),
    phone: fn("#phone"),
    sex,
    vip,
    question: fn("#question"),
    answer: fn("#answer"),
  }

  axios.post('http://124.223.14.236:3001/api/user/reg', data).then(res => {
    if (res.status !== 200) return alert(res.statusText)
    alert(res.data.msg)
  })




})